package cn.edu.hitwh.yibao.controller;

import cn.edu.hitwh.yibao.form.DiseaseForm;
import cn.edu.hitwh.yibao.service.DiseaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class DiseaseController {
    @Autowired
    private DiseaseService diseaseService;

    @GetMapping("/disease")
    public String disease() {
        return "/disease/select";
    }

    @PostMapping("/disease")
    public String diseaseResult(DiseaseForm diseaseForm, Model model) {
        return diseaseService.select(diseaseForm, model);
    }

    @GetMapping("/disease/addInit")
    public String addInit() {
        return "/disease/add";
    }

    @PostMapping("/disease/add")
    public String add(DiseaseForm diseaseForm, Model model) {
        return diseaseService.add(diseaseForm, model);
    }

    @GetMapping("/disease/updateInit")
    public String updateInit(@RequestParam("diseaseId") String diseaseId, Model model) {
        return diseaseService.updateInit(diseaseId, model);
    }

    @PostMapping("/disease/update")
    public String update(DiseaseForm diseaseForm, Model model) {
        return diseaseService.update(diseaseForm, model);
    }

    @GetMapping("/disease/delete")
    public String delete(@RequestParam("diseaseId") String diseaseId, Model model) {
        return diseaseService.delete(diseaseId, model);
    }

    @GetMapping("/disease/detail")
    public String detail(@RequestParam("diseaseId") String diseaseId, Model model) {
        return diseaseService.detail(diseaseId, model);
    }

    @GetMapping("/disease/addComplete")
    public String addComplete() {
        return "/disease/select";
    }

    @GetMapping("/disease/updateComplete")
    public String updateComplete() {
        return "/disease/select";
    }

    @GetMapping("/disease/deleteComplete")
    public String deleteComplete() {
        return "/disease/select";
    }
}